package gwt.trading.client;

import gwt.trading.client.geometry.Point;

/**
 * Translates a relative coordinate to a absolute coordinate.
 * 
 * @author Iulian Costan (iulian.costan@gmail.com)
 * 
 */
public class Translator {

	private Point origin;

	public Translator(Point origin) {
		this.origin = origin;
	}

	public Point getOrigin() {
		return origin;
	}

	public int translateXCoordinate(int xCoordinate) {
		return origin.getX() + xCoordinate;
	}

	public int translateYCoordinate(int yCoordinate) {
		return origin.getY() + yCoordinate;
	}

	public Translator move(int dx, int dy) {
		return new Translator(new Point(origin.getX() + dx, origin.getY() + dy));
	}

}
